#include<cstdio>
#include<iostream>
using namespace std;

const int MAX_STACK_SIZE = 1000;
int st[MAX_STACK_SIZE],top=0;

inline bool is_empty(){
	return top == 0;
}

inline bool is_full(){
	return top == MAX_STACK_SIZE;
}

inline void push(int data){
	if(!is_full())
		st[top++] = data;
}

inline bool pop(){
	if(!is_empty())	top--;
}

inline int get_top(){
	return st[top-1];
}

int main(){
	int n,t1,t2;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>t1;
		if(t1 == 2 && is_empty()){
			cout<<"impossible!"<<endl;
			return 0;
		}
		if(t1 == 1){
			cin>>t2;
			push(t2);
		}else{
			pop();
		}		
	}
	if(is_empty()){
		cout<<"impossible!"<<endl;
	}else{
		cout<<get_top()<<endl;
	}
	return 0;

}
